Skip to content

Add refresh_expires_in to OAuth token responses#756

Merged
rickyrombo merged 1 commit intomainfrom
mjp-oauth-refresh-expires-in
Apr 8, 2026
Merged

Add refresh_expires_in to OAuth token responses#756
rickyrombo merged 1 commit intomainfrom
mjp-oauth-refresh-expires-in

Conversation

@rickyrombo
Copy link
Copy Markdown
Contributor

Summary

Test plan

  • POST /v1/oauth/token (authorization_code grant) response includes refresh_expires_in: 2592000
  • POST /v1/oauth/token (refresh_token grant) response includes refresh_expires_in: 2592000
  • Existing expires_in field unchanged (still 3600)

🤖 Generated with Claude Code

Returns the refresh token TTL (30 days) in both the authorization code
exchange and refresh token grant responses, allowing clients to track
refresh token expiry and surface accurate session state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rickyrombo rickyrombo merged commit bd4e86a into main Apr 8, 2026
4 checks passed
@rickyrombo rickyrombo deleted the mjp-oauth-refresh-expires-in branch April 8, 2026 00:45
rickyrombo added a commit to AudiusProject/apps that referenced this pull request Apr 8, 2026
## Summary
- Adds `getAccessTokenExpiry()` / `getRefreshTokenExpiry()` to
`OAuthTokenStore` interface and all three implementations (Memory,
LocalStorage, AsyncStorage)
- `isAuthenticated()` now checks token expiry — returns false when
refresh token is expired, attempts silent refresh when access token is
expired
- `getUser()` retries once with a refreshed token on 401 instead of
immediately throwing
- `setTokens()` now accepts optional `expiresIn` / `refreshExpiresIn`
(seconds), which are persisted as absolute epoch timestamps

**Note:** Companion API change to return `refresh_expires_in` in the
token response: AudiusProject/api#756

## Test plan
- [x] All existing OAuth tests pass (74/74)
- [ ] `isAuthenticated()` returns false when refresh token is expired
- [ ] `isAuthenticated()` silently refreshes when access token is
expired but refresh token is valid
- [ ] `getUser()` retries and succeeds after token refresh on 401
- [ ] `getUser()` throws when both initial request and refresh fail
- [ ] Token expiry survives page reload (localStorage) and app restart
(AsyncStorage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant